#pragma once

#include <d3d9.h>
#include <d3dx9.h>
#include <sstream>


#include "IResourceObject.h"
#include "Helpers.h"

class CResourceBitmapFont : public IResourceObject
{
	protected:
		char*	m_fileName;
		int		m_imgWidth;
		int		m_imgHeight;
		int		m_cellWidth;
		int		m_cellHeight;
		char	m_fontWidthArray[256];
		DWORD	m_colorKey;

		IDirect3DTexture9*	m_sourceTexture;
		ID3DXSprite*		m_spriteInterface;

		bool LoadFontCSV(const char* _fileName);
		
	public:
		CResourceBitmapFont();
		~CResourceBitmapFont();
	
		bool CreateBitmapFont(const char *_fileName, int _imgWidth, int _imgHeight, int _cellWidth, int _cellHeight, DWORD _colorKey, const char *_fontCSVFile);

		bool OnInitResource(ICompHandler *_handler);
		bool OnFreeResource(ICompHandler *_handler);

		bool RenderBitmapText(const char *_text, IDirect3DDevice9 *_device, IDirect3DTexture9 **_targetTexture);
};